package com.yanqu.road.entity.activity.ghost;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

@FieldTypeAnnotation(tableName = "t_c_activity_ghost_data")
public class GhostData extends DataObject {

    @FieldTypeAnnotation(desc = "活动ID", select = true, update = true)
    private int activityId;
    @FieldTypeAnnotation(desc = "重置日期的0点")
    private long lastResetTime;
    @FieldTypeAnnotation(desc = "当前批次")
    private int maxBatchNo;

    @FieldTypeAnnotation(desc = "区服能力值")
    private Map<Long, List<Long>> abilityMap = new ConcurrentHashMap<>();
    @FieldTypeAnnotation(desc = "平均门客赚钱")
    private long avgAbility;
    @FieldTypeAnnotation(desc = "平均开服天数")
    private int avgOpenDay;

    @FieldTypeAnnotation(desc = "付费出战能力值（生成援兵后减少）")
    private long costAbility;

    @FieldTypeAnnotation(desc = "每批次boss总血量")
    private long batchBossTotalHp;

    // Map<批次，类型，BossId，Boss数据>
    private Map<Integer, Map<Integer, Map<Integer, GhostBossData>>> bossMap = new ConcurrentHashMap<>();
    private AtomicInteger nextBossId;
    private AtomicInteger bossCount;

    // Map<批次，商会UID，类型，情报数据>    类型：0发现，1击杀
    private Map<Integer, Map<String, Map<Integer, List<GhostUnionNews>>>> unionNewsMap = new ConcurrentHashMap<>();
    private AtomicInteger nextNewsId;

    // Map<批次，类型，List<送财奖励>>
    private Map<Integer, Map<Integer, List<GhostDisperseData>>> disperseMap = new ConcurrentHashMap<>();
    private AtomicInteger nextDisperseId;

    // Map<批次，BossId，UserId，伤害记录>
    private Map<Integer, Map<Integer, Map<Long, GhostAttackRecord>>> attackRecordMap = new ConcurrentHashMap<>();

    // Map<批次，类型，记录>   1发现，2全清
    private Map<Integer, Map<Integer, GhostDispersePlayer>> dispersePlayerMap = new ConcurrentHashMap<>();

    //商会，宝箱id，宝箱个数
    private Map<String, Map<Integer, Integer>> unionChest = new ConcurrentHashMap<>();

    public void setActivityId(int activityId) {
        if (activityId != this.activityId) {
            this.activityId = activityId;
            setUpdateOption();
        }
    }

    public void setLastResetTime(long lastResetTime) {
        if (lastResetTime != this.lastResetTime) {
            this.lastResetTime = lastResetTime;
            setUpdateOption();
        }
    }

    public void setMaxBatchNo(int maxBatchNo) {
        if (this.maxBatchNo != maxBatchNo) {
            this.maxBatchNo = maxBatchNo;
            setUpdateOption();
        }
    }

    public void setAbilityMap(Map<Long, List<Long>> abilityMap) {
        if (this.abilityMap != abilityMap) {
            this.abilityMap = abilityMap;
            setUpdateOption();
        }
    }

    public void setAvgAbility(long avgAbility) {
        if (this.avgAbility != avgAbility) {
            this.avgAbility = avgAbility;
            setUpdateOption();
        }
    }

    public void setAvgOpenDay(int avgOpenDay) {
        if (this.avgOpenDay != avgOpenDay) {
            this.avgOpenDay = avgOpenDay;
            setUpdateOption();
        }
    }

    public void setCostAbility(long costAbility) {
        if (this.costAbility != costAbility) {
            this.costAbility = costAbility;
            setUpdateOption();
        }
    }

    public void setBatchBossTotalHp(long batchBossTotalHp) {
        if (this.batchBossTotalHp != batchBossTotalHp) {
            this.batchBossTotalHp = batchBossTotalHp;
            setUpdateOption();
        }
    }

    public void setUnionChest(Map<String, Map<Integer, Integer>> unionChest) {
        this.unionChest = unionChest;
        setUpdateOption();
    }
    // ====================================


    public Map<Integer, Map<Integer, GhostDispersePlayer>> getDispersePlayerMap() {
        return dispersePlayerMap;
    }

    public void setDispersePlayerMap(Map<Integer, Map<Integer, GhostDispersePlayer>> dispersePlayerMap) {
        this.dispersePlayerMap = dispersePlayerMap;
    }

    public long getCostAbility() {
        return costAbility;
    }

    public Map<Integer, Map<Integer, Map<Long, GhostAttackRecord>>> getAttackRecordMap() {
        return attackRecordMap;
    }

    public void setAttackRecordMap(Map<Integer, Map<Integer, Map<Long, GhostAttackRecord>>> attackRecordMap) {
        this.attackRecordMap = attackRecordMap;
    }

    public int getNextDisperseId() {
        return nextDisperseId.getAndIncrement();
    }

    public void setNextDisperseId(AtomicInteger nextDisperseId) {
        this.nextDisperseId = nextDisperseId;
    }

    public Map<Integer, Map<Integer, List<GhostDisperseData>>> getDisperseMap() {
        return disperseMap;
    }

    public void setDisperseMap(Map<Integer, Map<Integer, List<GhostDisperseData>>> disperseMap) {
        this.disperseMap = disperseMap;
    }

    public int getNextBossId() {
        return this.nextBossId.getAndIncrement();
    }

    public int getNextNewsId() {
        return this.nextNewsId.getAndIncrement();
    }

    public void setBossMap(Map<Integer, Map<Integer, Map<Integer, GhostBossData>>> bossMap) {
        this.bossMap = bossMap;
    }

    public void setNextBossId(AtomicInteger nextBossId) {
        this.nextBossId = nextBossId;
    }

    public void setBossCount(AtomicInteger bossCount) {
        this.bossCount = bossCount;
    }

    public void setUnionNewsMap(Map<Integer, Map<String, Map<Integer, List<GhostUnionNews>>>> unionNewsMap) {
        this.unionNewsMap = unionNewsMap;
    }

    public void setNextNewsId(AtomicInteger nextNewsId) {
        this.nextNewsId = nextNewsId;
    }

    public int getActivityId() {
        return activityId;
    }

    public long getLastResetTime() {
        return lastResetTime;
    }

    public int getMaxBatchNo() {
        return maxBatchNo;
    }

    public Map<Long, List<Long>> getAbilityMap() {
        return abilityMap;
    }

    public long getAvgAbility() {
        return avgAbility;
    }

    public int getAvgOpenDay() {
        return avgOpenDay;
    }

    public Map<Integer, Map<Integer, Map<Integer, GhostBossData>>> getBossMap() {
        return bossMap;
    }

    public AtomicInteger getBossCount() {
        return bossCount;
    }

    public Map<Integer, Map<String, Map<Integer, List<GhostUnionNews>>>> getUnionNewsMap() {
        return unionNewsMap;
    }

    public long getBatchBossTotalHp() {
        return batchBossTotalHp;
    }

    public Map<String, Map<Integer, Integer>> getUnionChest() {
        return unionChest;
    }

}
